/***************************************************************************
 *   Copyright (C) 2008 by Justin L. Boss                                  *
 *   justin@rtechguys.com                                                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <QDesktopWidget>
#include <QDebug>
#include <kaboutapplicationdialog.h>
#include "kocean.h"
#include "koceansetting.h"

#define VERSION "0.6"

static KAboutData* s_aboutData = NULL;



class KOceanInterface : public KScreenSaverInterface
{
public:
    virtual KAboutData* aboutData()
    {
        return s_aboutData;
    }

    // function to create screen saver object
    virtual KScreenSaver* create(WId id)
    {
        return new KOcean(id);
    }

    // function to create setup dialog for screen saver
    virtual QDialog* setup()
    {
        return new KOceanSetup();
    }
};


int main(int argc, char*argv[])
{
    s_aboutData = new KAboutData("koceansaver", 0,
                ki18n("KOceanSaver"), VERSION,
                ki18n("KDE Ocean screensaver<br>Thanks to the following:<br><b>God</b> and his son <b>Son</b>.<br><b>KDE</b> – for making a great desktop to develop for<br><b>Nokia QT</b> - for making a great SDK and IDE<br><b>Blender</b> – for the best 3D designer out there.<br><b>The GNU Compiler</b> - what else can i say<br><b>Python</b> - what else can I say<br><b>John Stamp</b> for his help with KDE implementation<b>SourceForg for hosting the source."),
                KAboutData::License_GPL,
                ki18n("Copyright (C) 2008 Justin L. Boss"),
                KLocalizedString(),
                "http://koceansaver.sourceforge.net/",
                "justin@rtechguys.com");

    s_aboutData->addAuthor(ki18n("Justin L. Boss"),
                ki18n("I wish this to bring you the comfort and tranquility that comes form the ocean and the creatures that weightless glide through the water. Please remember that it was our grand creator who gave us these things."),
                "justin@rtechguys.com");

    KOceanInterface kss;
    return kScreenSaverMain(argc, argv, kss);
}

//-----------------------------------------------------------------------------
//! dialog to setup screen saver parameters
KOceanSetup::KOceanSetup(QWidget *parent) : KDialog(parent)
{
    settings = new Settings();
    setCaption(i18n("Setup KOceanSaver"));
    setButtons(Ok|Cancel|Help|Default);
    setDefaultButton(Ok);
    setModal(true);
    showButtonSeparator(true);
    setButtonText(Help, i18n("A&bout"));

    QWidget *main = new QWidget(this);
    setMainWidget(main);
    ui.setupUi(main);

    connect(this, SIGNAL(okClicked()), SLOT(slotOkPressed()));
    connect(this, SIGNAL(helpClicked()), SLOT(slotHelp()));
    connect(this, SIGNAL(defaultClicked()), SLOT(slotDefault()));
    connect(ui.kintspinbox_gridx,SIGNAL(valueChanged(int)),SLOT(slotUpdateGrid()));
    connect(ui.kintspinbox_gridy,SIGNAL(valueChanged(int)),SLOT(slotUpdateGrid()));
    //connect(ui.kintspinbox_Orca_Far,SIGNAL(valueChanged(int)),SLOT(set))

    ui.kplotwidget->setLimits(0,20,0,15);
    ui.kplotwidget->setForegroundColor(QColor(0,0,0));
    ui.kplotwidget->setBackgroundColor(QColor(255,255,255));
    ui.kplotwidget->setFrameStyle(2);
    ui.kplotwidget->setShowGrid(true);
    ui.kplotwidget->setGridColor(QColor(0,0,0));
    ui.kplotwidget->setBottomPadding(1);
    ui.kplotwidget->setTopPadding(0);
    ui.kplotwidget->setRightPadding(1);
    ui.kplotwidget->setLeftPadding(0);
    ui.kplotwidget->update();

    ui.checkBoxWaveEnabled->setChecked(settings->WaveEnabled);
    ui.kintspinbox_gridx->setValue(settings->WaveWidth);
    ui.kintspinbox_gridy->setValue(settings->WaveDepth);
    ui.kintspinbox_WaveSize->setValue(settings->WaveSize);
    ui.kintspinbox_WaveSpeed->setValue(settings->WaveSpeed);

    ui.checkBoxSampleBuffer->setChecked(settings->SampleBuffer);
    ui.horizontalSlider_Ambient->setValue(settings->Ambient);
    ui.horizontalSlider_CausticsFloor->setValue(settings->CausticsFloor);
    ui.horizontalSlider_CausticsWave->setValue(settings->CausticsWave);
    ui.horizontalSlider_Clarity->setValue(settings->Clarity);
    ui.horizontalSlider_Light->setValue(settings->Light);
    ui.kcolorcombo_Color->setColor(settings->Color);
    ui.kcolorcombo_Color->update();

    ui.kintspinbox_Orca_Count->setValue(settings->Orca_Count);
    ui.kintspinbox_Orca_Small->setValue(settings->Orca_Small);
    ui.kintspinbox_Orca_Larg->setValue(settings->Orca_Larg);
    ui.kintspinbox_Orca_Speed->setValue(settings->Orca_Speed);
    ui.kcombobox_Orca_Pattern->setCurrentIndex(settings->Orca_Pattern);
    ui.kintspinbox_Orca_Agility->setValue(settings->Orca_Agility);
    ui.kintspinbox_Orca_Far->setValue(settings->Orca_Far);
    ui.kintspinbox_Orca_Near->setValue(settings->Orca_Near);
    ui.kintspinbox_Orca_Depth->setValue(settings->Orca_Depth);
    ui.kintspinbox_Orca_TSpeed->setValue(settings->Orca_TSpeed);
    ui.kintspinbox_Orca_TMove->setValue(settings->Orca_TMove);

    ui.kintspinbox_LS_Count->setValue(settings->LS_Count);
    ui.kintspinbox_LS_Small->setValue(settings->LS_Small);
    ui.kintspinbox_LS_Larg->setValue(settings->LS_Larg);
    ui.kintspinbox_LS_Speed->setValue(settings->LS_Speed);
    ui.kcombobox_LS_Pattern->setCurrentIndex(settings->LS_Pattern);
    ui.kintspinbox_LS_Agility->setValue(settings->LS_Agility);
    ui.kintspinbox_LS_Far->setValue(settings->LS_Far);
    ui.kintspinbox_LS_Near->setValue(settings->LS_Near);
    ui.kintspinbox_LS_Depth->setValue(settings->LS_Depth);
    ui.kintspinbox_LS_TSpeed->setValue(settings->LS_TSpeed);
    ui.kintspinbox_LS_TMove->setValue(settings->LS_TMove);

    ui.kintspinbox_GW_Count->setValue(settings->GW_Count);
    ui.kintspinbox_GW_Small->setValue(settings->GW_Small);
    ui.kintspinbox_GW_Larg->setValue(settings->GW_Larg);
    ui.kintspinbox_GW_Speed->setValue(settings->GW_Speed);
    ui.kcombobox_GW_Pattern->setCurrentIndex(settings->GW_Pattern);
    ui.kintspinbox_GW_Agility->setValue(settings->GW_Agility);
    ui.kintspinbox_GW_Far->setValue(settings->GW_Far);
    ui.kintspinbox_GW_Near->setValue(settings->GW_Near);
    ui.kintspinbox_GW_Depth->setValue(settings->GW_Depth);
    ui.kintspinbox_GW_TSpeed->setValue(settings->GW_TSpeed);
    ui.kintspinbox_GW_TMove->setValue(settings->GW_TMove);

    ui.kintspinbox_BC_Count->setValue(settings->BC_Count);
    ui.kintspinbox_BC_Small->setValue(settings->BC_Small);
    ui.kintspinbox_BC_Larg->setValue(settings->BC_Larg);
    ui.kintspinbox_BC_Speed->setValue(settings->BC_Speed);
    ui.kcombobox_BC_Pattern->setCurrentIndex(settings->BC_Pattern);
    ui.kintspinbox_BC_Agility->setValue(settings->BC_Agility);
    ui.kintspinbox_BC_Far->setValue(settings->BC_Far);
    ui.kintspinbox_BC_Near->setValue(settings->BC_Near);
    ui.kintspinbox_BC_Depth->setValue(settings->BC_Depth);
    ui.kintspinbox_BC_TSpeed->setValue(settings->BC_TSpeed);
    ui.kintspinbox_BC_TMove->setValue(settings->BC_TMove);

    ui.kintspinbox_Sail_Count->setValue(settings->Sail_Count);
    ui.kintspinbox_Sail_Small->setValue(settings->Sail_Small);
    ui.kintspinbox_Sail_Larg->setValue(settings->Sail_Larg);
    ui.kintspinbox_Sail_Speed->setValue(settings->Sail_Speed);
    ui.kcombobox_Sail_Pattern->setCurrentIndex(settings->Sail_Pattern);
    ui.kintspinbox_Sail_Agility->setValue(settings->Sail_Agility);
    ui.kintspinbox_Sail_Far->setValue(settings->Sail_Far);
    ui.kintspinbox_Sail_Near->setValue(settings->Sail_Near);
    ui.kintspinbox_Sail_Depth->setValue(settings->Sail_Depth);
    ui.kintspinbox_Sail_TSpeed->setValue(settings->Sail_TSpeed);
    ui.kintspinbox_Sail_TMove->setValue(settings->Sail_TMove);

    ui.kintspinbox_Spade_Count->setValue(settings->Spade_Count);
    ui.kintspinbox_Spade_Small->setValue(settings->Spade_Small);
    ui.kintspinbox_Spade_Larg->setValue(settings->Spade_Larg);
    ui.kintspinbox_Spade_Speed->setValue(settings->Spade_Speed);
    ui.kcombobox_Spade_Pattern->setCurrentIndex(settings->Spade_Pattern);
    ui.kintspinbox_Spade_Agility->setValue(settings->Spade_Agility);
    ui.kintspinbox_Spade_Far->setValue(settings->Spade_Far);
    ui.kintspinbox_Spade_Near->setValue(settings->Spade_Near);
    ui.kintspinbox_Spade_Depth->setValue(settings->Spade_Depth);
    ui.kintspinbox_Spade_TSpeed->setValue(settings->Spade_TSpeed);
    ui.kintspinbox_Spade_TMove->setValue(settings->Spade_TMove);

    ui.kintspinbox_Tripletail_Count->setValue(settings->Tripletail_Count);
    ui.kintspinbox_Tripletail_Small->setValue(settings->Tripletail_Small);
    ui.kintspinbox_Tripletail_Larg->setValue(settings->Tripletail_Larg);
    ui.kintspinbox_Tripletail_Speed->setValue(settings->Tripletail_Speed);
    ui.kcombobox_Tripletail_Pattern->setCurrentIndex(settings->Tripletail_Pattern);
    ui.kintspinbox_Tripletail_Agility->setValue(settings->Tripletail_Agility);
    ui.kintspinbox_Tripletail_Far->setValue(settings->Tripletail_Far);
    ui.kintspinbox_Tripletail_Near->setValue(settings->Tripletail_Near);
    ui.kintspinbox_Tripletail_Depth->setValue(settings->Tripletail_Depth);
    ui.kintspinbox_Tripletail_TSpeed->setValue(settings->Tripletail_TSpeed);
    ui.kintspinbox_Tripletail_TMove->setValue(settings->Tripletail_TMove);

    ui.checkBox_Ship->setChecked(settings->ShipEnabled);
    ui.checkBox_Mausoleum->setChecked(settings->MausoleumEnabled);
    ui.checkBox_Rock->setChecked(settings->RockEnabled);
    ui.checkBox_SeaFloor->setChecked(settings->SeaFloorEnabled);

    ui.checkBox_Rocking->setChecked(settings->RockingEnabled);
    ui.doubleSpinBox_Amplitude->setValue(settings->Amplitude);
    ui.doubleSpinBox_Frequency->setValue(settings->Frequency);
}


KOceanSetup::~KOceanSetup()
{
    delete settings;
}


// Ok pressed - save settings and exit
void KOceanSetup::slotOkPressed()
{
    settings->WaveEnabled = ui.checkBoxWaveEnabled->checkState();
    settings->WaveWidth = ui.kintspinbox_gridx->value();
    settings->WaveDepth = ui.kintspinbox_gridy->value();
    settings->WaveSize = ui.kintspinbox_WaveSize->value();
    settings->WaveSpeed = ui.kintspinbox_WaveSpeed->value();

    settings->SampleBuffer = ui.checkBoxSampleBuffer->checkState();
    settings->Ambient = ui.horizontalSlider_Ambient->value();
    settings->CausticsFloor = ui.horizontalSlider_CausticsFloor->value();
    settings->CausticsWave = ui.horizontalSlider_CausticsWave->value();
    settings->Clarity = ui.horizontalSlider_Clarity->value();
    settings->Light = ui.horizontalSlider_Light->value();
    settings->Color = ui.kcolorcombo_Color->color();

    settings->Orca_Count = ui.kintspinbox_Orca_Count->value();
    settings->Orca_Small = ui.kintspinbox_Orca_Small->value();
    settings->Orca_Larg = ui.kintspinbox_Orca_Larg->value();
    settings->Orca_Speed = ui.kintspinbox_Orca_Speed->value();
    settings->Orca_Pattern = ui.kcombobox_Orca_Pattern->currentIndex();
    settings->Orca_Agility = ui.kintspinbox_Orca_Agility->value();
    settings->Orca_Far = ui.kintspinbox_Orca_Far->value();
    settings->Orca_Near = ui.kintspinbox_Orca_Near->value();
    settings->Orca_Depth = ui.kintspinbox_Orca_Depth->value();
    settings->Orca_TSpeed = ui.kintspinbox_Orca_TSpeed->value();
    settings->Orca_TMove = ui.kintspinbox_Orca_TMove->value();

    settings->LS_Count = ui.kintspinbox_LS_Count->value();
    settings->LS_Small = ui.kintspinbox_LS_Small->value();
    settings->LS_Larg = ui.kintspinbox_LS_Larg->value();
    settings->LS_Speed = ui.kintspinbox_LS_Speed->value();
    settings->LS_Pattern = ui.kcombobox_LS_Pattern->currentIndex();
    settings->LS_Agility = ui.kintspinbox_LS_Agility->value();
    settings->LS_Far = ui.kintspinbox_LS_Far->value();
    settings->LS_Near = ui.kintspinbox_LS_Near->value();
    settings->LS_Depth = ui.kintspinbox_LS_Depth->value();
    settings->LS_TSpeed = ui.kintspinbox_LS_TSpeed->value();
    settings->LS_TMove = ui.kintspinbox_LS_TMove->value();

    settings->GW_Count = ui.kintspinbox_GW_Count->value();
    settings->GW_Small = ui.kintspinbox_GW_Small->value();
    settings->GW_Larg = ui.kintspinbox_GW_Larg->value();
    settings->GW_Speed = ui.kintspinbox_GW_Speed->value();
    settings->GW_Pattern = ui.kcombobox_GW_Pattern->currentIndex();
    settings->GW_Agility = ui.kintspinbox_GW_Agility->value();
    settings->GW_Far = ui.kintspinbox_GW_Far->value();
    settings->GW_Near = ui.kintspinbox_GW_Near->value();
    settings->GW_Depth = ui.kintspinbox_GW_Depth->value();
    settings->GW_TSpeed = ui.kintspinbox_GW_TSpeed->value();
    settings->GW_TMove = ui.kintspinbox_GW_TMove->value();

    settings->BC_Count = ui.kintspinbox_BC_Count->value();
    settings->BC_Small = ui.kintspinbox_BC_Small->value();
    settings->BC_Larg = ui.kintspinbox_BC_Larg->value();
    settings->BC_Speed = ui.kintspinbox_BC_Speed->value();
    settings->BC_Pattern = ui.kcombobox_BC_Pattern->currentIndex();
    settings->BC_Agility = ui.kintspinbox_BC_Agility->value();
    settings->BC_Far = ui.kintspinbox_BC_Far->value();
    settings->BC_Near = ui.kintspinbox_BC_Near->value();
    settings->BC_Depth = ui.kintspinbox_BC_Depth->value();
    settings->BC_TSpeed = ui.kintspinbox_BC_TSpeed->value();
    settings->BC_TMove = ui.kintspinbox_BC_TMove->value();

    settings->Sail_Count = ui.kintspinbox_Sail_Count->value();
    settings->Sail_Small = ui.kintspinbox_Sail_Small->value();
    settings->Sail_Larg = ui.kintspinbox_Sail_Larg->value();
    settings->Sail_Speed = ui.kintspinbox_Sail_Speed->value();
    settings->Sail_Pattern = ui.kcombobox_Sail_Pattern->currentIndex();
    settings->Sail_Agility = ui.kintspinbox_Sail_Agility->value();
    settings->Sail_Far = ui.kintspinbox_Sail_Far->value();
    settings->Sail_Near = ui.kintspinbox_Sail_Near->value();
    settings->Sail_Depth = ui.kintspinbox_Sail_Depth->value();
    settings->Sail_TSpeed = ui.kintspinbox_Sail_TSpeed->value();
    settings->Sail_TMove = ui.kintspinbox_Sail_TMove->value();

    settings->Spade_Count = ui.kintspinbox_Spade_Count->value();
    settings->Spade_Small = ui.kintspinbox_Spade_Small->value();
    settings->Spade_Larg = ui.kintspinbox_Spade_Larg->value();
    settings->Spade_Speed = ui.kintspinbox_Spade_Speed->value();
    settings->Spade_Pattern = ui.kcombobox_Spade_Pattern->currentIndex();
    settings->Spade_Agility = ui.kintspinbox_Spade_Agility->value();
    settings->Spade_Far = ui.kintspinbox_Spade_Far->value();
    settings->Spade_Near = ui.kintspinbox_Spade_Near->value();
    settings->Spade_Depth = ui.kintspinbox_Spade_Depth->value();
    settings->Spade_TSpeed = ui.kintspinbox_Spade_TSpeed->value();
    settings->Spade_TMove = ui.kintspinbox_Spade_TMove->value();

    settings->Tripletail_Count = ui.kintspinbox_Tripletail_Count->value();
    settings->Tripletail_Small = ui.kintspinbox_Tripletail_Small->value();
    settings->Tripletail_Larg = ui.kintspinbox_Tripletail_Larg->value();
    settings->Tripletail_Speed = ui.kintspinbox_Tripletail_Speed->value();
    settings->Tripletail_Pattern = ui.kcombobox_Tripletail_Pattern->currentIndex();
    settings->Tripletail_Agility = ui.kintspinbox_Tripletail_Agility->value();
    settings->Tripletail_Far = ui.kintspinbox_Tripletail_Far->value();
    settings->Tripletail_Near = ui.kintspinbox_Tripletail_Near->value();
    settings->Tripletail_Depth = ui.kintspinbox_Tripletail_Depth->value();
    settings->Tripletail_TSpeed = ui.kintspinbox_Tripletail_TSpeed->value();
    settings->Tripletail_TMove = ui.kintspinbox_Tripletail_TMove->value();

    settings->ShipEnabled = ui.checkBox_Ship->checkState();
    settings->MausoleumEnabled = ui.checkBox_Mausoleum->checkState();
    settings->RockEnabled = ui.checkBox_Rock->checkState();
    settings->SeaFloorEnabled = ui.checkBox_SeaFloor->checkState();

    settings->RockingEnabled = ui.checkBox_Rocking->checkState();
    settings->Amplitude = ui.doubleSpinBox_Amplitude->value();
    settings->Frequency = ui.doubleSpinBox_Frequency->value();

    settings->save();
    accept();
}


void KOceanSetup::slotHelp()
{
    KAboutApplicationDialog mAbout(s_aboutData, this);
    mAbout.exec();
}


void KOceanSetup::slotDefault()
{
    settings->defaults();

    ui.horizontalSlider_Ambient->setValue(settings->Ambient);
    ui.horizontalSlider_CausticsFloor->setValue(settings->CausticsFloor);
    ui.horizontalSlider_CausticsWave->setValue(settings->CausticsWave);
    ui.horizontalSlider_Clarity->setValue(settings->Clarity);
    ui.horizontalSlider_Light->setValue(settings->Light);
    ui.kcolorcombo_Color->setColor(settings->Color);
    ui.kcolorcombo_Color->update();

    ui.checkBoxSampleBuffer->setChecked(settings->SampleBuffer);
    ui.checkBoxWaveEnabled->setChecked(settings->WaveEnabled);
    ui.kintspinbox_gridx->setValue(settings->WaveWidth);
    ui.kintspinbox_gridy->setValue(settings->WaveDepth);
    ui.kintspinbox_WaveSize->setValue(settings->WaveSize);
    ui.kintspinbox_WaveSpeed->setValue(settings->WaveSpeed);

    ui.kintspinbox_Orca_Count->setValue(settings->Orca_Count);
    ui.kintspinbox_Orca_Small->setValue(settings->Orca_Small);
    ui.kintspinbox_Orca_Larg->setValue(settings->Orca_Larg);
    ui.kintspinbox_Orca_Speed->setValue(settings->Orca_Speed);
    ui.kcombobox_Orca_Pattern->setCurrentIndex(settings->Orca_Pattern);
    ui.kintspinbox_Orca_Agility->setValue(settings->Orca_Agility);
    ui.kintspinbox_Orca_Far->setValue(settings->Orca_Far);
    ui.kintspinbox_Orca_Near->setValue(settings->Orca_Near);
    ui.kintspinbox_Orca_Depth->setValue(settings->Orca_Depth);
    ui.kintspinbox_Orca_TSpeed->setValue(settings->Orca_TSpeed);
    ui.kintspinbox_Orca_TMove->setValue(settings->Orca_TMove);

    ui.kintspinbox_LS_Count->setValue(settings->LS_Count);
    ui.kintspinbox_LS_Small->setValue(settings->LS_Small);
    ui.kintspinbox_LS_Larg->setValue(settings->LS_Larg);
    ui.kintspinbox_LS_Speed->setValue(settings->LS_Speed);
    ui.kcombobox_LS_Pattern->setCurrentIndex(settings->LS_Pattern);
    ui.kintspinbox_LS_Agility->setValue(settings->LS_Agility);
    ui.kintspinbox_LS_Far->setValue(settings->LS_Far);
    ui.kintspinbox_LS_Near->setValue(settings->LS_Near);
    ui.kintspinbox_LS_Depth->setValue(settings->LS_Depth);
    ui.kintspinbox_LS_TSpeed->setValue(settings->LS_TSpeed);
    ui.kintspinbox_LS_TMove->setValue(settings->LS_TMove);

    ui.kintspinbox_GW_Count->setValue(settings->GW_Count);
    ui.kintspinbox_GW_Small->setValue(settings->GW_Small);
    ui.kintspinbox_GW_Larg->setValue(settings->GW_Larg);
    ui.kintspinbox_GW_Speed->setValue(settings->GW_Speed);
    ui.kcombobox_GW_Pattern->setCurrentIndex(settings->GW_Pattern);
    ui.kintspinbox_GW_Agility->setValue(settings->GW_Agility);
    ui.kintspinbox_GW_Far->setValue(settings->GW_Far);
    ui.kintspinbox_GW_Near->setValue(settings->GW_Near);
    ui.kintspinbox_GW_Depth->setValue(settings->GW_Depth);
    ui.kintspinbox_GW_TSpeed->setValue(settings->GW_TSpeed);
    ui.kintspinbox_GW_TMove->setValue(settings->GW_TMove);

    ui.kintspinbox_BC_Count->setValue(settings->BC_Count);
    ui.kintspinbox_BC_Small->setValue(settings->BC_Small);
    ui.kintspinbox_BC_Larg->setValue(settings->BC_Larg);
    ui.kintspinbox_BC_Speed->setValue(settings->BC_Speed);
    ui.kcombobox_BC_Pattern->setCurrentIndex(settings->BC_Pattern);
    ui.kintspinbox_BC_Agility->setValue(settings->BC_Agility);
    ui.kintspinbox_BC_Far->setValue(settings->BC_Far);
    ui.kintspinbox_BC_Near->setValue(settings->BC_Near);
    ui.kintspinbox_BC_Depth->setValue(settings->BC_Depth);
    ui.kintspinbox_BC_TSpeed->setValue(settings->BC_TSpeed);
    ui.kintspinbox_BC_TMove->setValue(settings->BC_TMove);

    ui.kintspinbox_Sail_Count->setValue(settings->Sail_Count);
    ui.kintspinbox_Sail_Small->setValue(settings->Sail_Small);
    ui.kintspinbox_Sail_Larg->setValue(settings->Sail_Larg);
    ui.kintspinbox_Sail_Speed->setValue(settings->Sail_Speed);
    ui.kcombobox_Sail_Pattern->setCurrentIndex(settings->Sail_Pattern);
    ui.kintspinbox_Sail_Agility->setValue(settings->Sail_Agility);
    ui.kintspinbox_Sail_Far->setValue(settings->Sail_Far);
    ui.kintspinbox_Sail_Near->setValue(settings->Sail_Near);
    ui.kintspinbox_Sail_Depth->setValue(settings->Sail_Depth);
    ui.kintspinbox_Sail_TSpeed->setValue(settings->Sail_TSpeed);
    ui.kintspinbox_Sail_TMove->setValue(settings->Sail_TMove);

    ui.kintspinbox_Spade_Count->setValue(settings->Spade_Count);
    ui.kintspinbox_Spade_Small->setValue(settings->Spade_Small);
    ui.kintspinbox_Spade_Larg->setValue(settings->Spade_Larg);
    ui.kintspinbox_Spade_Speed->setValue(settings->Spade_Speed);
    ui.kcombobox_Spade_Pattern->setCurrentIndex(settings->Spade_Pattern);
    ui.kintspinbox_Spade_Agility->setValue(settings->Spade_Agility);
    ui.kintspinbox_Spade_Far->setValue(settings->Spade_Far);
    ui.kintspinbox_Spade_Near->setValue(settings->Spade_Near);
    ui.kintspinbox_Spade_Depth->setValue(settings->Spade_Depth);
    ui.kintspinbox_Spade_TSpeed->setValue(settings->Spade_TSpeed);
    ui.kintspinbox_Spade_TMove->setValue(settings->Spade_TMove);

    ui.kintspinbox_Tripletail_Count->setValue(settings->Tripletail_Count);
    ui.kintspinbox_Tripletail_Small->setValue(settings->Tripletail_Small);
    ui.kintspinbox_Tripletail_Larg->setValue(settings->Tripletail_Larg);
    ui.kintspinbox_Tripletail_Speed->setValue(settings->Tripletail_Speed);
    ui.kcombobox_Tripletail_Pattern->setCurrentIndex(settings->Tripletail_Pattern);
    ui.kintspinbox_Tripletail_Agility->setValue(settings->Tripletail_Agility);
    ui.kintspinbox_Tripletail_Far->setValue(settings->Tripletail_Far);
    ui.kintspinbox_Tripletail_Near->setValue(settings->Tripletail_Near);
    ui.kintspinbox_Tripletail_Depth->setValue(settings->Tripletail_Depth);
    ui.kintspinbox_Tripletail_TSpeed->setValue(settings->Tripletail_TSpeed);
    ui.kintspinbox_Tripletail_TMove->setValue(settings->Tripletail_TMove);

    ui.checkBox_Ship->setChecked(settings->ShipEnabled);
    ui.checkBox_Mausoleum->setChecked(settings->MausoleumEnabled);
    ui.checkBox_Rock->setChecked(settings->RockEnabled);
    ui.checkBox_SeaFloor->setChecked(settings->SeaFloorEnabled);

    ui.checkBox_Rocking->setChecked(settings->RockingEnabled);
    ui.doubleSpinBox_Amplitude->setValue(settings->Amplitude);
    ui.doubleSpinBox_Frequency->setValue(settings->Frequency);
}

void KOceanSetup::slotUpdateGrid()
{
    ui.kplotwidget->setLimits(0,ui.kintspinbox_gridx->value(),0,ui.kintspinbox_gridy->value());
}

//-----------------------------------------------------------------------------


KOcean::KOcean(WId id) : KScreenSaver(id)
{
    QPalette p = palette();
    p.setColor(backgroundRole(), Qt::black);
    setPalette(p);

    ocean = new Ocean();

    embed(ocean);

    ocean->show();
}


KOcean::~KOcean()
{
    delete ocean;
}

